<template>
  <div>
    <table>
      <thead>
        <tr>
          <th v-for="it in list" :key="it.id">{{ it.name }}</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="item in listB" :key="item.id">
          <td v-for="it in list" :key="it.id">{{ item[it.id] }}</td>
          <td><button @click="btn(item)">确定</button></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      require: true,
    },
    listB: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    btn(item) {
        // "click"  是父组件的事件名
      this.$emit("click", item);
    },
  },
};
</script>
<style scoped>
th{background-color: rgba(165, 42, 42, 0.664);width: 200px;height: 40px}
    td{width: 200px;height: 40px;background-color: cadetblue;text-align: center;}
</style>